/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.anniversary.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.builder.ToStringBuilder;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.lang.reflect.Field;

/**
* @website https://el-admin.vip
* @description /
* @author Jiayin Wei
* @date 2020-07-28
**/

@Getter
@Setter
@Entity
@Data
@Table(name="v_student_industry_statistics")
public class StudentIndustryStatistic implements Serializable {

    @Id
    @Column(name = "id")
    @ApiModelProperty(value = "编号ID")
    private Long id;

    @Column(name = "college")
    @ApiModelProperty(value = "院系名称")
    private String college;

    @Column(name = "major")
    @ApiModelProperty(value = "专业")
    private String major;

    @Column(name = "industry")
    @ApiModelProperty(value = "行业")
    private String industry;

    @Column(name = "count")
    @ApiModelProperty(value = "总数")
    private Long count;

    public void copy(StudentIndustryStatistic source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }

    @Override
    public String toString() {
        ToStringBuilder builder = new ToStringBuilder(this);
        Field[] fields = this.getClass().getDeclaredFields();
        try {
            for (Field f : fields) {
                f.setAccessible(true);
                builder.append(f.getName(), f.get(this)).append("\n");
            }
        } catch (Exception e) {
            builder.append("toString builder encounter an error");
        }
        return builder.toString();
    }
}
